﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;

namespace VmcRemote.PpcRemote
{
    [DesignTimeVisible(true)]
    public partial class PictureButton : PictureBox, ISupportInitialize
    {
        bool pushed;

        public PictureButton() { }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (pushed)
            {
                Rectangle border = base.ClientRectangle;
                border.Width--;
                border.Height--;
                e.Graphics.DrawRectangle(new Pen(Color.Black), border);
            }
        }

        protected override void OnPaintBackground(PaintEventArgs e) { }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            pushed = true;
            base.Invalidate();
            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            pushed = false;
            base.Invalidate();
            base.OnMouseUp(e);
            Common.Sound.PlayBeep();
        }


        #region ISupportInitialize Members
        bool initialising;
        public void BeginInit()
        {
            initialising = true;
            //throw new NotImplementedException();
        }

        public void EndInit()
        {
            initialising = false;
            //throw new NotImplementedException();
        }

        #endregion
    }
}
